<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
*/

/**
 * Description of EstadoDAOClass
 *
 * @author Gustavo
 */
include_once 'ConfigClass.php';
include_once '../negocios/EstadoClass.php';
class EstadoDAOClass {
    private $conn;
    private $option;

    public function  __construct() {
        $this->conn = new ConfigClass();
    }

    public function  __destruct() {

    }

    public function selecionaEstados() {
        $this->conn->conecta();

        $estado = new EstadoClass();

        $query = "SELECT id_estado, sigla FROM estado ORDER BY estado ASC";
        $res = pg_query($query);
        $this->option = '<select name="estado" id="estado">';
        $this->option .= '<option value="">Escolha</option>';
        while($busca = pg_fetch_array($res)) {
            $estado->setId_estado($busca['id_estado']);
            $estado->setSigla($busca['sigla']);
            $this->option .= '<option value="'.$estado->getId_estado().'">'.$estado->getSigla().'</option>';
        }
        $this->option .= '</select>';
        return print $this->option;

        $this->conn->desconecta();
    }
}
?>